package com.ruoyi.project.system.mapper;

import com.ruoyi.project.system.domain.SiyuQuery;
import com.ruoyi.project.system.domain.vo.SiyuQueryVo;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;
import java.util.Map;

@Mapper
public interface SiyuQueryMapper {

    int selectTelCount(String tel);

    Map<String, Object> selectQueryInfo(Integer queryId, Integer productId);

    int insertQueryInfo(Integer queryId, Integer productId, String requestId, String info);

    int updateCommTelByQueryId(Integer queryId, String tel);

    int insertComm(Integer queryId, String tel);

    Map<String, Long> commResult(Integer queryId);

    Map<String, String> selectCommByQueryId(Integer queryId, String item);

    String queryCommAddressBookByQueryId(Integer queryId);

    String queryCommTextMessageByQueryId(Integer queryId);

    String queryCommCallLogByQueryId(Integer queryId);

    String queryCommAppAuthByQueryId(Integer queryId);

    Integer selectCommQueryIdBytel(String tel);

    int updateCommByAddressBook(String tel, String addressBook);

    int updateCommByTextMessage(String tel, String textMessage);

    int updateCommByCallLog(String tel, String callLog);

    int updateCommAppAuth(String tel, String appAuth);

    String selectStreamReport(Integer queryId);

    int insertStreamReport(Integer queryId, String info);

    int updateStreamReport(Integer queryId, String info);

    SiyuQuery selectSiyuQueryByMoreKeyword(String moreKeyword);

    Map<String, Object> selectAuthKey(Integer queryId);

    SiyuQuery selectSiyuQueryInfoByQueryId(SiyuQuery siyuQuery);

    SiyuQuery selectSiyuQueryByQueryId(Integer queryId);

    List<SiyuQuery> quickList(SiyuQuery siyuQuery);

    List<SiyuQueryVo> selectSiyuQueryList(SiyuQuery siyuQuery);

    int insertSiyuQuery(SiyuQuery siyuQuery);

    int updateYysInfo(String moreKeyword, String yysInfo);

    int updateYysReport(Long queryId);

    int updateSiyuQuery(SiyuQuery siyuQuery);

    int removeInviteList(Integer[] queryIds);

    int deleteCommByQueryIds(Integer[] queryIds);

    int deleteSiyuQueryByQueryIds(Integer[] queryIds);

    @Delete("delete from siyu_query where create_time < DATE_ADD(CURDATE(), INTERVAL -2 WEEK);")
    int deleteAfterTwoWeek();

    @Delete("delete from comm where queryId in (select query_id from siyu_query where create_time < DATE_ADD(CURDATE(), INTERVAL -2 WEEK));")
    int deleteAfterCommTwoWeek();

    @Delete("delete from siyu_charge where create_time < DATE_ADD(CURDATE(), INTERVAL -2 WEEK);")
    int deleteAfterChargeTwoWeek();

    @Delete("delete from siyu_recharge where create_time < DATE_ADD(CURDATE(), INTERVAL -2 WEEK);")
    int deleteAfterRechargeTwoWeek();

    @Select("SELECT query_id FROM siyu_query WHERE create_time < DATE_ADD(CURDATE(), INTERVAL - 2 WEEK );")
    List<Integer> queryId();

    int deleteAppauth(List<Integer> ids);

    int deleteTextmessage(List<Integer> ids);

    int deleteAddressbook(List<Integer> ids);

    int deleteCalllog(List<Integer> ids);
}
